/*
 * @Author: limit
 * @Date: 2021-03-30 13:34:19
 * @LastEditTime: 2021-09-09 17:40:14
 * @LastEditors: limit
 * @FilePath: /basic-services/src/mixins/modules/list.js
 * @Description: 由limit创建！
 */

import TableLayout from '@/components/TableLayout/index';
import { getToken } from '@/utils/auth';

export default {
  components: { TableLayout },
  data () {
    return {
      lists: [],
      listQuery: {},
      dialogType: 0,
      typeList: ['添加', '修改', '查看'],
      userId: this.sessionData("get", "userId"), // 当前登录人Id
      deptId: this.sessionData("get", "deptId"), // 当前部门id
      //tenantId: this.sessionData("get", "tenantId"), // 当前租户id
      listLoading: false,
      dialogVisible: false,
      uploadHeader: { Authorization: 'bearer ' + getToken() },
      uploadData: { //tenantId: this.sessionData("get", "tenantId") },
      temporary: {},
    }
  },
  methods: {
    // 重置表单
    restFormData (formName) {
      let newForm = {};
      for (const key in formName) {
        if (Object.hasOwnProperty.call(formName, key)) {
          const element = formName[key];
          newForm[key] = '';
          if (Object.prototype.toString.call(element) == '[object Object]') newForm[key] = {};
          if (Object.prototype.toString.call(element) == '[object Array]') newForm[key] = [];
        }
      }
      return newForm;
    },
  }
}